#@head() 
#@header()
<title>辅助工具</title>
#@aside("custser")
<link href="#(path)/assets/plugins/umeditor1.2.3-utf8-jsp/themes/default/css/umeditor.css" type="text/css" rel="stylesheet">
<script type="text/javascript" src="#(path)/assets/plugins/umeditor1.2.3-utf8-jsp/third-party/template.min.js"></script>
<script type="text/javascript" charset="utf-8" src="#(path)/assets/plugins/umeditor1.2.3-utf8-jsp/umeditor.config.js"></script>
<script type="text/javascript" charset="utf-8" src="#(path)/assets/plugins/umeditor1.2.3-utf8-jsp/umeditor.min.js"></script>
<script type="text/javascript" src="#(path)/assets/plugins/umeditor1.2.3-utf8-jsp/lang/zh-cn/zh-cn.js"></script>
<script type="text/javascript" src="#(path)/assets/js/jquery.tmpl.min.js"></script>
<div class="content-wrapper">
	<section class="content">
		<div class="nav-tabs-custom">
            <ul class="nav nav-tabs">
             <li class="active"><a href="#(path)/admin/page/custser-addrepository">新建词条</a></li>
				
            </ul>
            <div class="tab-content">
              <div class="tab-pane active" id="tab_1">
				<div class="box-body">
					<table id="example1" style="width:70%;" class="table table-striped">
						<tbody>
							<tr>
								<th align="right" style="">标题：</th>
								<td><input id="name" type="text" class="form-control" placeholder="名称"></td>
							</tr>
							<tr>
								<th align="right" style="">内容：</th>
								<td>
									<script type="text/plain" id="myEditor" style="width:100%;;height:240px;">
									</script>
									<script type="text/javascript">
										var um = UM.getEditor('myEditor');
									</script>
								</td>
							</tr>
							
						</tbody>
					</table>
				</div>
				<div class="box-footer">
					<button id="submit_addcarousel" type="submit" style="margin-left:50px;" class="btn btn-info ">提交</button>
					<button onclick="window.location.href='#(path)/admin/page/custser-repository'" type="submit" style="margin-left:10px;" class="btn  ">取消</button>
				  </div>
              </div>
            </div> 
            <!-- /.tab-content -->
          </div> 
	</section>
</div>
#@footer()

<script>
var id = GetRequest(id);
$.getJSON("/notice/info?token=#(session.token??)&id="+id.id, function(userinfo) {
	
	var item = userinfo.data;
	$("#name").val(item.name);
	$("#status").val(item.status);
	$("#summary").val(item.summary);
	$("#pic").val(item.pic);
	$("#type").val(item.type);
	if(!$.isBlank(item.contents)){
		UM.getEditor('myEditor').execCommand('insertHtml', item.contents);
	}
	
});
function GetRequest() {  
   var url = location.search; //获取url中"?"符后的字串  
   var theRequest = new Object();  
   if (url.indexOf("?") != -1) {  
	  var str = url.substr(1);  
	  strs = str.split("&");  
	  for(var i = 0; i < strs.length; i ++) {  
		 theRequest[strs[i].split("=")[0]]=unescape(strs[i].split("=")[1]);  
	  }  
   }  
   return theRequest;  
}  
$("#submit_addcarousel").click(function(){
	var neirong = UM.getEditor('myEditor').getContentTxt();
	
	ajax("/notice/edit?token=#(session.token??)&id="+id.id,
		{"type":"repository","summary":"","pic":"","contents":neirong,"name":$("#name").val(),"status":"enable"},function(data){
		
		if(data.code=='success'){
			layer.msg(data.msg,{icon:1,time:1000},function(){
				window.location.href="#(path)/admin/page/custser-repository";
			}); 
		}else{
			layer.msg(data.msg,{icon:2,time:2000}); 
		}
	});
});
</script>
</body>
</html>

